//
//  DetailCell.m
//  GoldOperationClient
//
//  Created by yaxue wang on 16/9/23.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "DetailCell.h"
#import "DetailModel.h"
#import "SDImageCache.h"
#import "UIImageView+WebCache.h"

@interface DetailCell()
{
    UIImageView *_headImg;
}
//@property (strong, nonatomic)  UIImageView *headImg;
@property (strong, nonatomic)  UILabel *nameLab;
@property (strong, nonatomic)  UILabel *contentLab;

@property (strong, nonatomic)  UILabel *timeLab;
@property (strong, nonatomic)  UILabel *line;

@end
@implementation DetailCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.topLine=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 0.5)];
        [self addSubview:self.topLine];
        //lab名字
        _nameLab= [[UILabel alloc ]init];
        _nameLab.font=FF(14);
        _nameLab.textColor=[UIColor whiteColor];
        [self addSubview:_nameLab];
        [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(25);
            make.width.equalTo(@(75));
            make.top.equalTo(self).offset(10);
            
        }];
        _nameLab.textAlignment=NSTextAlignmentLeft;
        //时间
        _timeLab=[[UILabel alloc]init];
        _timeLab.font=FF(12);
        _timeLab.textAlignment=NSTextAlignmentLeft;
        _timeLab.textColor=[UIColor whiteColor];
        [self addSubview:_timeLab];
        [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(25);
            make.width.equalTo(@(75));
            make.top.equalTo(_nameLab.mas_bottom).offset(10);
            
        }];

        //描述
        _contentLab= [[UILabel alloc ]init];
        [self addSubview:_contentLab];
        
        [_contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_nameLab.mas_right).offset(10);
            make.right.equalTo(self).offset(-15);
            make.top.equalTo(_nameLab);
            
        }];
        _contentLab.numberOfLines=0;
        _contentLab.font=F(12);
        _contentLab.textColor=[UIColor whiteColor];
        _contentLab.numberOfLines=0;
        
        
        
        //进度点img
        _headImg=[[UIImageView alloc]init];//WithFrame:CGRectMake(CGRectGetMaxX(_timeLab.frame), CGRectGetMaxY(_contentLab.frame), 50,50)];
        [self addSubview:_headImg];
        [_headImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.equalTo(@50);
            make.width.equalTo(@50);
            make.left.equalTo(_timeLab.mas_right).offset(10);
            make.bottom.equalTo(self.mas_bottom).offset(-10);
        }];
       
        //下面的一条线
//        self.line =[[UILabel alloc]initWithFrame:CGRectMake(0,self.bounds.size.height-0.5 , WindowWidth, 0.5)];
        _line=[[UILabel alloc]init];
        [self addSubview:_line];
        [_line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.equalTo(@0.5);
            make.width.equalTo(self);
            make.bottom.equalTo(self);
        }];
        _line.backgroundColor = [UIColor colorFromHexString:@"565656"];


        
    }
    return self;
}
- (void)setModel:(id)model{
    
    DetailModel *order = model;

    if ((order.P_name==nil||[order.P_name isEqualToString:@""]))
    {
        _nameLab.text =@"";
        
    }else{
        
        _nameLab.text=[NSString stringWithFormat:@"%@",order.P_name];
        
    }
    if (order.P_created==nil||[order.P_created isEqualToString:@""]) {
        self.timeLab.text =@"";
        
    }else
    {
        NSString *time =[order.P_created substringWithRange:NSMakeRange(5, 11)];
         self.timeLab.text=time;
    }
    
    if (order.P_describe==nil||[order.P_describe isEqualToString:@""])
    {
        _contentLab.text =@"";
        
    }else
    {
        _contentLab.text = order.P_describe;
        
    }
     NSString* urlString =[CClass getCacheData:qnDomain];
    NSURL *url =[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",urlString,order.P_image]];
    [_headImg sd_setImageWithURL:url];
       _headImg.userInteractionEnabled=YES;
    [_headImg bk_whenTapped:^{
        [XWScanImage scanBigImageWithImageView:_headImg];
    }];


}


@end
